const mysql = require('mysql')

const conn = mysql.createPool({
    //主机地址
    host: 'localhost',
    //用户名
    user: 'root',
    //密码
    password: '',
    //数据库名称
    database: 'test'
})

function query(sql, callback) {
    conn.getConnection(function (err, connection) {
        connection.query(sql, function (err, rows) {
            callback(err, rows)
            connection.release()
        })
    })
}

exports.query = query
